Debian Codegraph @

trace/internal/telemetry/scope_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package telemetry
5
6 import "testing"
7
8 func TestScopeEncoding(t *testing.T) {
9 scope := &Scope{
10 Name: "go.opentelemetry.io/otel/trace/internal/telemetry/test",
11 Version: "v0.0.1",
12 Attrs: []Attr{String("department", "ops")},
13 DroppedAttrs: 1,
14 }
15
16 t.Run("CamelCase", runJSONEncodingTests(scope, []byte(`{
17 "name": "go.opentelemetry.io/otel/trace/internal/telemetry/test",
18 "version": "v0.0.1",
19 "attributes": [
20 {
21 "key": "department",
22 "value": {
23 "stringValue": "ops"
24 }
25 }
26 ],
27 "droppedAttributesCount": 1
28 }`)))
29
30 t.Run("SnakeCase/Unmarshal", runJSONUnmarshalTest(scope, []byte(`{
31 "name": "go.opentelemetry.io/otel/trace/internal/telemetry/test",
32 "version": "v0.0.1",
33 "attributes": [
34 {
35 "key": "department",
36 "value": {
37 "string_value": "ops"
38 }
39 }
40 ],
41 "dropped_attributes_count": 1
42 }`)))
43 }