Skip to content

Commit

Permalink
Transaction Source
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Dec 5, 2022
1 parent f219a81 commit 33562f0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dynamic_sampling_context_test.go
Expand Up @@ -93,7 +93,7 @@ func TestDynamicSamplingContextFromTransaction(t *testing.T) {
Dsn: "http://public@example.com/sentry/1",
Release: "1.0.0",
})
txn := StartTransaction(ctx, "name")
txn := StartTransaction(ctx, "name", TransctionSource(SourceURL))
txn.TraceID = TraceIDFromHex("d49d9bf66f13450b81f65bc51cf49c03")
return txn
}(),
Expand Down
19 changes: 13 additions & 6 deletions interfaces.go
Expand Up @@ -222,6 +222,11 @@ type SDKMetaData struct {
transactionSource TransactionSource
}

// Contains information about how the name of the transaction was determined.
type TransactionInfo struct {
Source TransactionSource `json:"source,omitempty"`
}

// EventID is a hexadecimal string representing a unique uuid4 for an Event.
// An EventID must be 32 characters long, lowercase and not have any dashes.
type EventID string
Expand Down Expand Up @@ -255,9 +260,10 @@ type Event struct {

// The fields below are only relevant for transactions.

Type string `json:"type,omitempty"`
StartTime time.Time `json:"start_timestamp"`
Spans []*Span `json:"spans,omitempty"`
Type string `json:"type,omitempty"`
StartTime time.Time `json:"start_timestamp"`
Spans []*Span `json:"spans,omitempty"`
TransactionInfo *TransactionInfo `json:"transaction_info,omitempty"`

// The fields below are not part of the final JSON payload.

Expand Down Expand Up @@ -303,9 +309,10 @@ func (e *Event) defaultMarshalJSON() ([]byte, error) {
// be sent for transactions. They shadow the respective fields in Event
// and are meant to remain nil, triggering the omitempty behavior.

Type json.RawMessage `json:"type,omitempty"`
StartTime json.RawMessage `json:"start_timestamp,omitempty"`
Spans json.RawMessage `json:"spans,omitempty"`
Type json.RawMessage `json:"type,omitempty"`
StartTime json.RawMessage `json:"start_timestamp,omitempty"`
Spans json.RawMessage `json:"spans,omitempty"`
TransactionInfo json.RawMessage `json:"transaction_info,omitempty"`
}

x := errorEvent{event: (*event)(e)}
Expand Down
1 change: 1 addition & 0 deletions tracing.go
Expand Up @@ -83,6 +83,7 @@ func StartSpan(ctx context.Context, operation string, options ...SpanOption) *Sp
Op: operation,
StartTime: time.Now(),
Sampled: SampledUndefined,
Source: SourceCustom,

ctx: context.WithValue(ctx, spanContextKey{}, &span),
parent: parent,
Expand Down
1 change: 1 addition & 0 deletions tracing_test.go
Expand Up @@ -207,6 +207,7 @@ func TestStartChild(t *testing.T) {
ParentSpanID: child.ParentSpanID,
Op: child.Op,
Sampled: SampledTrue,
Source: child.Source,
},
},
}
Expand Down
9 changes: 5 additions & 4 deletions transport.go
Expand Up @@ -98,11 +98,12 @@ func transactionEnvelopeFromBody(event *Event, dsn *Dsn, sentAt time.Time, body
var b bytes.Buffer
enc := json.NewEncoder(&b)

dsc := event.sdkMetaData.dsc
// Construct the trace envolope header
var trace = map[string]string{}

for k, v := range dsc.Entries {
trace[k] = v
if dsc := event.sdkMetaData.dsc; dsc.HasEntries() {
for k, v := range dsc.Entries {
trace[k] = v
}
}

// Envelope header
Expand Down

0 comments on commit 33562f0

Please sign in to comment.