// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"

import (
	
	
	
	
	
)

// Scope is the identifying values of the instrumentation scope.
type Scope struct {
	Name         string `json:"name,omitempty"`
	Version      string `json:"version,omitempty"`
	Attrs        []Attr `json:"attributes,omitempty"`
	DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
}

// UnmarshalJSON decodes the OTLP formatted JSON contained in data into r.
func ( *Scope) ( []byte) error {
	 := json.NewDecoder(bytes.NewReader())

	,  := .Token()
	if  != nil {
		return 
	}
	if  != json.Delim('{') {
		return errors.New("invalid Scope type")
	}

	for .More() {
		,  := .Token()
		if  != nil {
			if errors.Is(, io.EOF) {
				// Empty.
				return nil
			}
			return 
		}

		,  := .(string)
		if ! {
			return fmt.Errorf("invalid Scope field: %#v", )
		}

		switch  {
		case "name":
			 = .Decode(&.Name)
		case "version":
			 = .Decode(&.Version)
		case "attributes":
			 = .Decode(&.Attrs)
		case "droppedAttributesCount", "dropped_attributes_count":
			 = .Decode(&.DroppedAttrs)
		default:
			// Skip unknown.
		}

		if  != nil {
			return 
		}
	}
	return nil
}