// Internal until spec is finalized. // https://github.com/open-telemetry/oteps/blob/master/text/0111-auto-resource-detection.md internal ResourceBuilder AddDetector(IResourceDetector resourceDetector) { Guard.Null(resourceDetector, nameof(resourceDetector)); Resource resource = resourceDetector.Detect(); if (resource != null) { this.resources.Add(resource); } return(this); }
// Internal until spec is finalized. // https://github.com/open-telemetry/oteps/blob/master/text/0111-auto-resource-detection.md internal ResourceBuilder AddDetector(IResourceDetector resourceDetector) { if (resourceDetector == null) { throw new ArgumentNullException(nameof(resourceDetector)); } Resource resource = resourceDetector.Detect(); if (resource != null) { this.resources.Add(resource); } return(this); }
/// <summary> /// Add resource detector to ResourceBuilder. /// </summary> /// <param name="resourceBuilder"><see cref="ResourceBuilder"/> being configured.</param> /// <param name="resourceDetector"><see cref="IResourceDetector"/> being added.</param> /// <returns>The instance of <see cref="ResourceBuilder"/> to chain the calls.</returns> public static ResourceBuilder AddDetector(this ResourceBuilder resourceBuilder, IResourceDetector resourceDetector) { if (resourceDetector == null) { throw new ArgumentNullException(nameof(resourceDetector)); } var resourceAttributes = resourceDetector.Detect(); if (resourceAttributes != null) { resourceBuilder.AddAttributes(resourceAttributes); } return(resourceBuilder); }