Skip to content

Commit

Permalink
Handle "collection-agent" argument as Datadog agent URL
Browse files Browse the repository at this point in the history
  • Loading branch information
nsavoire committed May 31, 2024
1 parent 1392fad commit ea696c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
defaultProbabilisticThreshold = tracer.ProbabilisticThresholdMax
defaultProbabilisticInterval = 1 * time.Minute
defaultArgSendErrorFrames = false
defaultArgCollAgentAddr = "http://localhost:8126/profiling/v1/input"
defaultArgCollAgentAddr = "http://localhost:8126"

// This is the X in 2^(n + x) where n is the default hardcoded map size value
defaultArgMapScaleFactor = 0
Expand Down
11 changes: 9 additions & 2 deletions reporter/datadog_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package reporter
import (
"bytes"
"context"
"net/url"
"os"
"strings"
"time"
Expand All @@ -25,6 +26,8 @@ import (
// Assert that we implement the full Reporter interface.
var _ Reporter = (*DatadogReporter)(nil)

const profilingEndPoint = "/profiling/v1/input"

// DatadogReporter receives and transforms information to be OTLP/profiles compliant.
type DatadogReporter struct {
// client for the connection to the receiver.
Expand Down Expand Up @@ -333,8 +336,12 @@ func (r *DatadogReporter) reportProfile(ctx context.Context) error {
tags = append(tags, "service:otel-profiling-agent")
}
log.Infof("tags: %v", tags)
err := uploadProfiles(ctx, []profileData{{name: "cpu.pprof", data: b.Bytes()}},
time.Unix(int64(startTS), 0), time.Unix(int64(endTS), 0), r.agentAddr, tags)
profilingURL, err := url.JoinPath(r.agentAddr, profilingEndPoint)
if err != nil {
return err
}
err = uploadProfiles(ctx, []profileData{{name: "cpu.pprof", data: b.Bytes()}},
time.Unix(int64(startTS), 0), time.Unix(int64(endTS), 0), profilingURL, tags)

return err
}
Expand Down

0 comments on commit ea696c2

Please sign in to comment.