Skip to content

Commit

Permalink
feat(trace-exporter): use the same resource mapping for metrics and t…
Browse files Browse the repository at this point in the history
…races (#635)

In the trace exporter, stop passing `includeUnsupportedResources` param
(false by default). This param controls if the mapping function should
return `cloud_run_revision` and `cloud_function` monitored resources.
This is equivalent to what we do in [Go](https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/v0.44.0/internal/resourcemapping/resourcemapping.go) and Java GoogleCloudPlatform/opentelemetry-operations-java#250

Deprecate the `includeUnsupportedResources` parameter by splitting the
function def into a deprecated and non-deprecated overload. It is no
longer needed but the package is marked stable so I will save the
breaking change.
  • Loading branch information
aabmass authored Oct 5, 2023
1 parent db2664c commit 2e789b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function transformResourceToAttributes(
resourceFilter?: RegExp,
stringifyArrayAttributes?: boolean
): Attributes {
const monitoredResource = mapOtelResourceToMonitoredResource(resource, true);
const monitoredResource = mapOtelResourceToMonitoredResource(resource);
const attributes: ot.SpanAttributes = {};

if (resourceFilter) {
Expand Down
19 changes: 14 additions & 5 deletions packages/opentelemetry-resource-util/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,22 @@ export interface MonitoredResource {
* https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/v1.8.0/internal/resourcemapping/resourcemapping.go#L51
*
* @param resource the OTel Resource
* @param includeUnsupportedResources if true, will return the most specific monitored resource
* possible even if that resource does not support custom metrics. If false, will fallback to
* generic resources which support custom metrics. See
* https://cloud.google.com/monitoring/custom-metrics for more information on which resources
* supporting custom metrics.
* @returns the corresponding GCM MonitoredResource
*/
export function mapOtelResourceToMonitoredResource(
resource: IResource
): MonitoredResource;
/**
* @deprecated This overload is deprecated, do not pass the includeUnsupportedResources boolean
* parameter. It will be removed in the next major version release.
*
* @param resource the OTel Resource
* @returns the corresponding GCM MonitoredResource
*/
export function mapOtelResourceToMonitoredResource(
resource: IResource,
includeUnsupportedResources: boolean | undefined
): MonitoredResource;
export function mapOtelResourceToMonitoredResource(
resource: IResource,
includeUnsupportedResources = false
Expand Down

0 comments on commit 2e789b0

Please sign in to comment.