static void insertResourceAttributes()

in exporters/trace/src/main/java/com/google/cloud/opentelemetry/trace/TraceTranslator.java [132:152]


  static void insertResourceAttributes(Resource resource, Map<String, AttributeValue> accumulator) {
    // First add the GCP resource labels.
    GcpResource gcpResource = ResourceTranslator.mapResource(resource);
    gcpResource
        .getResourceLabels()
        .getLabels()
        .forEach(
            (k, v) -> {
              accumulator.put(
                  "g.co/r/" + gcpResource.getResourceType() + "/" + k, toAttributeValueString(v));
            });
    // Next add in all the otel resource labels if they don't already exist.
    resource
        .getAttributes()
        .forEach(
            (key, value) -> {
              if (!accumulator.containsKey(key.getKey())) {
                accumulator.put(key.getKey(), toAttributeValueProto(key, value));
              }
            });
  }