Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing otel attributes to Spans exported to Cloud Trace #365

Merged
merged 9 commits into from
Apr 26, 2022
1 change: 1 addition & 0 deletions e2e-test-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ WORKDIR /workspace/e2e-test-server/

# In-repo dependencies
COPY exporter/trace/ ../exporter/trace/
COPY internal/resourcemapping/ ../internal/resourcemapping

# cache deps before copying source so that source changes don't invalidate our
# downloaded layer and we don't need to re-download as much.
Expand Down
7 changes: 5 additions & 2 deletions e2e-test-server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ require (
cloud.google.com/go/iam v0.1.1 // indirect
cloud.google.com/go/pubsub v1.19.0
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.4.0
go.opentelemetry.io/otel v1.6.2
go.opentelemetry.io/otel v1.6.3
go.opentelemetry.io/otel/sdk v1.6.2
go.opentelemetry.io/otel/trace v1.6.2
go.opentelemetry.io/otel/trace v1.6.3
google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf
)

require (
cloud.google.com/go v0.100.2 // indirect
cloud.google.com/go/compute v1.5.0 // indirect
cloud.google.com/go/trace v1.2.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.0.0-00010101000000-000000000000 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -36,4 +37,6 @@ require (

replace github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace => ../exporter/trace

replace github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping => ../internal/resourcemapping

retract v1.0.0-RC1
6 changes: 4 additions & 2 deletions e2e-test-server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,15 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4d0A+Dxa3rYPenSN5ZeS9qHUvE8rlObiLRXTY=
go.opentelemetry.io/otel v1.6.2 h1:iLrj1F5ydCSVc4CGjBX2ou/QRav3C8xHjHlVoch6g4w=
go.opentelemetry.io/otel v1.6.2/go.mod h1:MUBZHaB2cm6CahEBHQPq9Anos7IXynP/noVpjsxQTSc=
go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE=
go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI=
go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ=
go.opentelemetry.io/otel/sdk v1.6.2 h1:wxY+YrfpGJfjxtm7SFBMJp9APDMZjDG+ErZOs/wkubg=
go.opentelemetry.io/otel/sdk v1.6.2/go.mod h1:M2r4VCm1Yurk4E+fWtP2p+QzFDHMFEqhGdbtQ7zRf+k=
go.opentelemetry.io/otel/trace v1.6.2 h1:oY7i1k6XD/ozlGo7ASy+H1UdkNcj9cPfuklaYSXtoFk=
go.opentelemetry.io/otel/trace v1.6.2/go.mod h1:RMqfw8Mclba1p7sXDmEDBvrB8jw65F6GOoN1fyyXTzk=
go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc=
go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
7 changes: 5 additions & 2 deletions example/trace/http/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ go 1.17

replace github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace => ../../../exporter/trace

replace github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping => ../../../internal/resourcemapping

require (
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.4.0
github.com/davecgh/go-spew v1.1.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0
go.opentelemetry.io/otel v1.6.2
go.opentelemetry.io/otel v1.6.3
go.opentelemetry.io/otel/sdk v1.6.2
go.opentelemetry.io/otel/trace v1.6.2
go.opentelemetry.io/otel/trace v1.6.3
)

require (
cloud.google.com/go/compute v1.5.0 // indirect
cloud.google.com/go/trace v1.2.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.0.0-00010101000000-000000000000 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand Down
6 changes: 4 additions & 2 deletions example/trace/http/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,18 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0/go.mod h1:PFmBsWbldL1kiWZk9+0LBZz2brhByaGsvp6pRICMlPE=
go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ=
go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ=
go.opentelemetry.io/otel v1.6.2 h1:iLrj1F5ydCSVc4CGjBX2ou/QRav3C8xHjHlVoch6g4w=
go.opentelemetry.io/otel v1.6.2/go.mod h1:MUBZHaB2cm6CahEBHQPq9Anos7IXynP/noVpjsxQTSc=
go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE=
go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI=
go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ=
go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw=
go.opentelemetry.io/otel/sdk v1.6.2 h1:wxY+YrfpGJfjxtm7SFBMJp9APDMZjDG+ErZOs/wkubg=
go.opentelemetry.io/otel/sdk v1.6.2/go.mod h1:M2r4VCm1Yurk4E+fWtP2p+QzFDHMFEqhGdbtQ7zRf+k=
go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE=
go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0=
go.opentelemetry.io/otel/trace v1.6.2 h1:oY7i1k6XD/ozlGo7ASy+H1UdkNcj9cPfuklaYSXtoFk=
go.opentelemetry.io/otel/trace v1.6.2/go.mod h1:RMqfw8Mclba1p7sXDmEDBvrB8jw65F6GOoN1fyyXTzk=
go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc=
go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
7 changes: 5 additions & 2 deletions exporter/collector/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ require (
github.com/stretchr/testify v1.7.1
go.opencensus.io v0.23.0
go.opentelemetry.io/collector/model v0.49.0
go.opentelemetry.io/otel v1.6.2
go.opentelemetry.io/otel v1.6.3
go.opentelemetry.io/otel/sdk v1.6.2
go.opentelemetry.io/otel/trace v1.6.2
go.opentelemetry.io/otel/trace v1.6.3
google.golang.org/api v0.74.0
google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf
google.golang.org/grpc v1.45.0
Expand All @@ -21,6 +21,7 @@ require (
require (
cloud.google.com/go/monitoring v1.4.0
cloud.google.com/go/trace v1.2.0
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.0.0-00010101000000-000000000000
github.com/google/go-cmp v0.5.7
go.opentelemetry.io/collector/pdata v0.49.0
go.uber.org/zap v1.21.0
Expand Down Expand Up @@ -50,3 +51,5 @@ require (
)

replace github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace => ../trace

replace github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping => ../../internal/resourcemapping
6 changes: 4 additions & 2 deletions exporter/collector/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,15 @@ go.opentelemetry.io/collector/model v0.49.0/go.mod h1:nOYQv9KoFPs6ihJwOi24qB209E
go.opentelemetry.io/collector/pdata v0.49.0 h1:aYj5rOlRC0x7lGXbc185LMsMMoY/pjOTXr5s1O2SzXs=
go.opentelemetry.io/collector/pdata v0.49.0/go.mod h1:YwmKuiFhNgtmhRdpi8Q8FAWPa0AwJTCSlssSsAtuRcY=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4d0A+Dxa3rYPenSN5ZeS9qHUvE8rlObiLRXTY=
go.opentelemetry.io/otel v1.6.2 h1:iLrj1F5ydCSVc4CGjBX2ou/QRav3C8xHjHlVoch6g4w=
go.opentelemetry.io/otel v1.6.2/go.mod h1:MUBZHaB2cm6CahEBHQPq9Anos7IXynP/noVpjsxQTSc=
go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE=
go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI=
go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ=
go.opentelemetry.io/otel/sdk v1.6.2 h1:wxY+YrfpGJfjxtm7SFBMJp9APDMZjDG+ErZOs/wkubg=
go.opentelemetry.io/otel/sdk v1.6.2/go.mod h1:M2r4VCm1Yurk4E+fWtP2p+QzFDHMFEqhGdbtQ7zRf+k=
go.opentelemetry.io/otel/trace v1.6.2 h1:oY7i1k6XD/ozlGo7ASy+H1UdkNcj9cPfuklaYSXtoFk=
go.opentelemetry.io/otel/trace v1.6.2/go.mod h1:RMqfw8Mclba1p7sXDmEDBvrB8jw65F6GOoN1fyyXTzk=
go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc=
go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
Expand Down
4 changes: 3 additions & 1 deletion exporter/collector/integrationtest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.17
require (
contrib.go.opencensus.io/exporter/stackdriver v0.13.11
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector v0.28.0
github.com/aws/aws-sdk-go v1.42.49 // indirect
github.com/google/go-cmp v0.5.7
github.com/stretchr/testify v1.7.1
go.opencensus.io v0.23.0
Expand All @@ -24,6 +23,8 @@ require (
cloud.google.com/go/monitoring v1.4.0 // indirect
cloud.google.com/go/trace v1.2.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.4.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.0.0-00010101000000-000000000000 // indirect
github.com/aws/aws-sdk-go v1.42.49 // indirect
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
Expand Down Expand Up @@ -58,4 +59,5 @@ require (
replace (
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector => ../../collector
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace => ../../trace
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping => ../../../internal/resourcemapping
)
170 changes: 17 additions & 153 deletions exporter/collector/monitoredresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,167 +21,38 @@ import (
semconv "go.opentelemetry.io/collector/model/semconv/v1.8.0"
"go.opentelemetry.io/collector/pdata/pcommon"
monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres"
)

const (
awsAccount = "aws_account"
awsEc2Instance = "aws_ec2_instance"
clusterName = "cluster_name"
containerName = "container_name"
gceInstance = "gce_instance"
genericNode = "generic_node"
genericTask = "generic_task"
instanceID = "instance_id"
job = "job"
k8sCluster = "k8s_cluster"
k8sContainer = "k8s_container"
k8sNode = "k8s_node"
k8sPod = "k8s_pod"
location = "location"
namespace = "namespace"
namespaceName = "namespace_name"
nodeID = "node_id"
nodeName = "node_name"
podName = "pod_name"
region = "region"
taskID = "task_id"
zone = "zone"
"github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping"
)

var (
// monitoredResourceMappings contains mappings of GCM resource label keys onto mapping config from OTel
// resource for a given monitored resource type.
monitoredResourceMappings = map[string]map[string]struct {
// OTel resource keys to try and populate the resource label from. For entries with
// multiple OTel resource keys, the keys' values will be coalesced in order until there
// is a non-empty value.
otelKeys []string
// If none of the otelKeys are present in the Resource, fallback to this literal value
fallbackLiteral string
}{
gceInstance: {
zone: {otelKeys: []string{semconv.AttributeCloudAvailabilityZone}},
instanceID: {otelKeys: []string{semconv.AttributeHostID}},
},
k8sContainer: {
location: {otelKeys: []string{semconv.AttributeCloudAvailabilityZone}},
clusterName: {otelKeys: []string{semconv.AttributeK8SClusterName}},
namespaceName: {otelKeys: []string{semconv.AttributeK8SNamespaceName}},
podName: {otelKeys: []string{semconv.AttributeK8SPodName}},
containerName: {otelKeys: []string{semconv.AttributeK8SContainerName}},
},
k8sPod: {
location: {otelKeys: []string{semconv.AttributeCloudAvailabilityZone}},
clusterName: {otelKeys: []string{semconv.AttributeK8SClusterName}},
namespaceName: {otelKeys: []string{semconv.AttributeK8SNamespaceName}},
podName: {otelKeys: []string{semconv.AttributeK8SPodName}},
},
k8sNode: {
location: {otelKeys: []string{semconv.AttributeCloudAvailabilityZone}},
clusterName: {otelKeys: []string{semconv.AttributeK8SClusterName}},
nodeName: {otelKeys: []string{semconv.AttributeK8SNodeName}},
},
k8sCluster: {
location: {otelKeys: []string{semconv.AttributeCloudAvailabilityZone}},
clusterName: {otelKeys: []string{semconv.AttributeK8SClusterName}},
},
awsEc2Instance: {
instanceID: {otelKeys: []string{semconv.AttributeHostID}},
region: {otelKeys: []string{semconv.AttributeCloudAvailabilityZone}},
awsAccount: {otelKeys: []string{semconv.AttributeCloudAccountID}},
},
genericTask: {
location: {
otelKeys: []string{
semconv.AttributeCloudAvailabilityZone,
semconv.AttributeCloudRegion,
},
fallbackLiteral: "global",
},
namespace: {otelKeys: []string{semconv.AttributeServiceNamespace}},
job: {otelKeys: []string{semconv.AttributeServiceName}},
taskID: {otelKeys: []string{semconv.AttributeServiceInstanceID}},
},
genericNode: {
location: {
otelKeys: []string{
semconv.AttributeCloudAvailabilityZone,
semconv.AttributeCloudRegion,
},
fallbackLiteral: "global",
},
namespace: {otelKeys: []string{semconv.AttributeServiceNamespace}},
nodeID: {otelKeys: []string{semconv.AttributeHostID, semconv.AttributeHostName}},
},
type attributes struct {
Attrs *pdata.Map
}

func (attrs *attributes) GetString(key string) (string, bool) {
value, ok := attrs.Attrs.Get(key)
if ok {
return value.AsString(), ok
}
)
return "", false
}

// Transforms pdata Resource to a GCM Monitored Resource. Any additional metric labels from the
// resource are also returned.
func (m *metricMapper) resourceToMonitoredResource(
resource pdata.Resource,
) (*monitoredrespb.MonitoredResource, labels) {
attrs := resource.Attributes()
cloudPlatform := getStringOrEmpty(attrs, semconv.AttributeCloudPlatform)

var mr *monitoredrespb.MonitoredResource
switch cloudPlatform {
case semconv.AttributeCloudPlatformGCPComputeEngine:
mr = createMonitoredResource(gceInstance, attrs)
case semconv.AttributeCloudPlatformGCPKubernetesEngine:
// Try for most to least specific k8s_container, k8s_pod, etc
if _, ok := attrs.Get(semconv.AttributeK8SContainerName); ok {
mr = createMonitoredResource(k8sContainer, attrs)
} else if _, ok := attrs.Get(semconv.AttributeK8SPodName); ok {
mr = createMonitoredResource(k8sPod, attrs)
} else if _, ok := attrs.Get(semconv.AttributeK8SNodeName); ok {
mr = createMonitoredResource(k8sNode, attrs)
} else {
mr = createMonitoredResource(k8sCluster, attrs)
}
case semconv.AttributeCloudPlatformAWSEC2:
mr = createMonitoredResource(awsEc2Instance, attrs)
default:
// Fallback to generic_task
_, hasServiceName := attrs.Get(semconv.AttributeServiceName)
_, hasServiceInstanceID := attrs.Get(semconv.AttributeServiceInstanceID)
if hasServiceName && hasServiceInstanceID {
mr = createMonitoredResource(genericTask, attrs)
} else {
// If not possible, fallback to generic_node
mr = createMonitoredResource(genericNode, attrs)
}
gmr := resourcemapping.ResourceAttributesToMonitoredResource(&attributes{
Attrs: &attrs,
})
mr := &monitoredrespb.MonitoredResource{
Type: gmr.Type,
Labels: gmr.Labels,
}
return mr, m.resourceToMetricLabels(resource)
}

func createMonitoredResource(
monitoredResourceType string,
resourceAttrs pdata.Map,
) *monitoredrespb.MonitoredResource {
mappings := monitoredResourceMappings[monitoredResourceType]
mrLabels := make(map[string]string, len(mappings))

for mrKey, mappingConfig := range mappings {
mrValue := ""
// Coalesce the possible keys in order
for _, otelKey := range mappingConfig.otelKeys {
mrValue = getStringOrEmpty(resourceAttrs, otelKey)
if mrValue != "" {
break
}
}
if mrValue == "" {
mrValue = mappingConfig.fallbackLiteral
}
mrLabels[mrKey] = mrValue
}
return &monitoredrespb.MonitoredResource{
Type: monitoredResourceType,
Labels: mrLabels,
}
}

// resourceToMetricLabels converts the Resource into metric labels needed to uniquely identify
// the timeseries.
func (m *metricMapper) resourceToMetricLabels(
Expand All @@ -208,10 +79,3 @@ func (m *metricMapper) resourceToMetricLabels(
})
return attributesToLabels(attrs)
}

func getStringOrEmpty(attributes pdata.Map, key string) string {
if val, ok := attributes.Get(key); ok {
return val.StringVal()
}
return ""
}
8 changes: 6 additions & 2 deletions exporter/trace/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ require (
github.com/googleinterns/cloud-operations-api-mock v0.0.0-20200709193332-a1e58c29bdd3
github.com/stretchr/testify v1.7.1
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0
go.opentelemetry.io/otel v1.6.2
go.opentelemetry.io/otel v1.6.3
go.opentelemetry.io/otel/sdk v1.6.2
go.opentelemetry.io/otel/trace v1.6.2
go.opentelemetry.io/otel/trace v1.6.3
golang.org/x/net v0.0.0-20220325170049-de3da57026de // indirect
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886 // indirect
Expand All @@ -21,6 +21,8 @@ require (
google.golang.org/protobuf v1.28.0
)

require github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.0.0-00010101000000-000000000000

require (
cloud.google.com/go/compute v1.5.0 // indirect
github.com/davecgh/go-spew v1.1.0 // indirect
Expand All @@ -36,3 +38,5 @@ require (
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)

replace github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping => ../../internal/resourcemapping
Loading