Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
feat: Use sentry-go (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Jul 21, 2020
1 parent 224be2a commit 0f60c27
Show file tree
Hide file tree
Showing 11 changed files with 698 additions and 342 deletions.
2 changes: 1 addition & 1 deletion exporter/sentryexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ func TestLoadConfig(t *testing.T) {
NameVal: "sentry/2",
TypeVal: "sentry",
},
DSN: "https://key@host/path/id",
DSN: "https://key@host/path/42",
})
}
138 changes: 138 additions & 0 deletions exporter/sentryexporter/data_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package sentryexporter

import "github.com/getsentry/sentry-go"

/*
for trace d6c4f03650bd47699ec65c84352b6208:
rootSpan1 <- childSpan1 <- childChildSpan1
rootSpan1 <- childSpan2
rootSpan2 <- root2childSpan
orphanSpan
*/

var (
rootSpan1 = &sentry.Span{
TraceID: "d6c4f03650bd47699ec65c84352b6208",
SpanID: "1cc4b26ab9094ef0",
ParentSpanID: "",
Description: "/api/users/{user_id}",
Op: "http.server",
Tags: map[string]string{
"organization": "12345",
"status_message": "HTTP OK",
"span_kind": "server",
},
StartTimestamp: unixNanoToTime(5),
EndTimestamp: unixNanoToTime(10),
Status: "ok",
}

childSpan1 = &sentry.Span{
TraceID: "d6c4f03650bd47699ec65c84352b6208",
SpanID: "93ba92db3fa24752",
ParentSpanID: "1cc4b26ab9094ef0",
Description: `SELECT * FROM user WHERE "user"."id" = {id}`,
Op: "db",
Tags: map[string]string{
"function_name": "get_users",
"status_message": "MYSQL OK",
"span_kind": "server",
},
StartTimestamp: unixNanoToTime(5),
EndTimestamp: unixNanoToTime(7),
Status: "ok",
}

childChildSpan1 = &sentry.Span{
TraceID: "d6c4f03650bd47699ec65c84352b6208",
SpanID: "1fa8913ec3814d34",
ParentSpanID: "93ba92db3fa24752",
Description: `DB locked`,
Op: "db",
Tags: map[string]string{
"db_status": "oh no im locked rn",
"status_message": "MYSQL OK",
"span_kind": "server",
},
StartTimestamp: unixNanoToTime(6),
EndTimestamp: unixNanoToTime(7),
Status: "ok",
}

childSpan2 = &sentry.Span{
TraceID: "d6c4f03650bd47699ec65c84352b6208",
SpanID: "34efcde268684bb0",
ParentSpanID: "1cc4b26ab9094ef0",
Description: "Serialize stuff",
Op: "",
Tags: map[string]string{
"span_kind": "server",
},
StartTimestamp: unixNanoToTime(7),
EndTimestamp: unixNanoToTime(10),
Status: "ok",
}

orphanSpan1 = &sentry.Span{
TraceID: "d6c4f03650bd47699ec65c84352b6208",
SpanID: "6241111811384fae",
ParentSpanID: "1930bb5cc45c4003",
Description: "A random span",
Op: "",
StartTimestamp: unixNanoToTime(3),
EndTimestamp: unixNanoToTime(6),
Status: "ok",
}

rootSpan2 = &sentry.Span{
TraceID: "d6c4f03650bd47699ec65c84352b6208",
SpanID: "4c7f56556ffe4e4a",
ParentSpanID: "",
Description: "Navigating to fancy website",
Op: "pageload",
Tags: map[string]string{
"status_message": "HTTP OK",
"span_kind": "client",
},
StartTimestamp: unixNanoToTime(0),
EndTimestamp: unixNanoToTime(5),
Status: "ok",
}

root2childSpan = &sentry.Span{
TraceID: "d6c4f03650bd47699ec65c84352b6208",
SpanID: "7ff3c8daf8184fee",
ParentSpanID: "4c7f56556ffe4e4a",
Description: "<FancyReactComponent />",
Op: "react",
Tags: map[string]string{
"span_kind": "server",
},
StartTimestamp: unixNanoToTime(4),
EndTimestamp: unixNanoToTime(5),
Status: "ok",
}

transaction1 = getTestTransaction(rootSpan1, []*sentry.Span{childSpan1, childChildSpan1, childSpan2})
transaction2 = getTestTransaction(rootSpan2, []*sentry.Span{root2childSpan})
)

func getTestTransaction(rootSpan *sentry.Span, childSpans []*sentry.Span) *sentry.Event {
transaction := transactionFromSpan(rootSpan)
transaction.Spans = childSpans
return transaction
}
1 change: 1 addition & 0 deletions exporter/sentryexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (f *Factory) CreateDefaultConfig() configmodels.Exporter {
TypeVal: typeStr,
NameVal: typeStr,
},
DSN: "",
}
}

Expand Down
2 changes: 1 addition & 1 deletion exporter/sentryexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestCreateDefaultConfig(t *testing.T) {
assert.NoError(t, configcheck.ValidateConfig(cfg))
}

func TestCreateTraceExporter(t *testing.T) {
func TestCreateTraceExporterDefault(t *testing.T) {
factory := &Factory{}
cfg := factory.CreateDefaultConfig()

Expand Down
4 changes: 2 additions & 2 deletions exporter/sentryexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sentry
go 1.14

require (
github.com/getsentry/sentry-go v0.6.1
github.com/getsentry/sentry-go v0.6.2-0.20200604090419-1d0b5e638037
github.com/google/go-cmp v0.4.0
github.com/open-telemetry/opentelemetry-collector v0.3.1-0.20200511154150-871119061598
github.com/open-telemetry/opentelemetry-proto v0.3.0
github.com/stretchr/testify v1.5.1
github.com/stretchr/testify v1.6.1
go.uber.org/zap v1.15.0
)
Loading

0 comments on commit 0f60c27

Please sign in to comment.