fields

package
v0.0.0-...-b055b18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package fields provides definitions and functions related to the definition of telemetry fields.

Index

Constants

View Source
const (
	// Application name. Value is always "azd".
	ServiceNameKey = semconv.ServiceNameKey // service.name
	// Application version.
	ServiceVersionKey = semconv.ServiceVersionKey // service.version

	// The operating system type.
	OSTypeKey = semconv.OSTypeKey // os.type

	// The operating system version.
	//
	// Examples:
	//   - On Windows systems: The Windows version 10.x.x
	//   - On Unix-based systems: The release portion of uname. https://en.wikipedia.org/wiki/Uname#Examples
	//   - On MacOS: The MacOS version. For example: 12.5.1 for macOS Monterey
	OSVersionKey = semconv.OSVersionKey // os.version

	// The CPU architecture the host system is running on.
	HostArchKey = semconv.HostArchKey // host.arch

	// The version of the runtime of this process, as returned by the runtime without
	// modification.
	ProcessRuntimeVersionKey = semconv.ProcessRuntimeVersionKey // process.runtime.version

	// A unique ID associated to the machine the application is installed on.
	//
	// This shares implementation with VSCode's machineId and can match exactly on a given device, although there are no
	// guarantees.
	MachineIdKey = attribute.Key("machine.id")

	// An enumeration of possible environments that the application is running on.
	//
	// Example: Desktop, Azure Pipelines, Visual Studio.
	//
	// See EnvDesktop for complete set of values.
	ExecutionEnvironmentKey = attribute.Key("execution.environment")

	// Installer used to install the application. Set in .installed-by.txt file
	// located in the same folder as the executable.
	//
	// Example: "msi", "brew", "choco", "rpm", "deb"
	InstalledByKey = attribute.Key("service.installer")
)

Application-level fields. Guaranteed to be set and available for all events.

View Source
const (
	// Object ID of the principal.
	ObjectIdKey = attribute.Key(contracts.UserAuthUserId) // user_AuthenticatedId
	// Tenant ID of the principal.
	TenantIdKey = attribute.Key("ad.tenant.id")
	// The type of account. See AccountTypeUser for all possible options.
	AccountTypeKey = attribute.Key("ad.account.type")
	// Currently selected Subscription ID.
	SubscriptionIdKey = attribute.Key("ad.subscription.id")
)

Context level fields. Availability depends on the command running.

View Source
const (
	// Hashed template ID metadata
	ProjectTemplateIdKey = attribute.Key("project.template.id")
	// Hashed template.version metadata
	ProjectTemplateVersionKey = attribute.Key("project.template.version")
	// Hashed project name. Could be used as an indicator for number of different azd projects.
	ProjectNameKey = attribute.Key("project.name")
	// The collection of hashed service hosts in the project.
	ProjectServiceHostsKey = attribute.Key("project.service.hosts")
	// The collection of service targets (resolved service hosts) in the project.
	ProjectServiceTargetsKey = attribute.Key("project.service.targets")
	// The collection of hashed service languages in the project.
	ProjectServiceLanguagesKey = attribute.Key("project.service.languages")
	// The service language being executed.
	ProjectServiceLanguageKey = attribute.Key("project.service.language")
)

Project (azure.yaml) related attributes

View Source
const (
	// Flags set by the user. Only parsed flag names are available. Values are not recorded.
	CmdFlags = attribute.Key("cmd.flags")
	// Number of positional arguments set.
	CmdArgsCount = attribute.Key("cmd.args.count")
	// The command invocation entrypoint.
	//
	// The command invocation is formatted using [events.GetCommandEventName]. This makes it consistent with how
	// commands are represented in telemetry.
	CmdEntry = attribute.Key("cmd.entry")
)

Command entry-point attributes

View Source
const (
	// A desktop environment. The user is directly interacting with azd via a terminal.
	EnvDesktop = "Desktop"

	EnvVisualStudio     = "Visual Studio"
	EnvVisualStudioCode = "Visual Studio Code"
	EnvCloudShell       = "Azure CloudShell"

	EnvUnknownCI          = "UnknownCI"
	EnvAzurePipelines     = "Azure Pipelines"
	EnvGitHubActions      = "GitHub Actions"
	EnvAppVeyor           = "AppVeyor"
	EnvBamboo             = "Bamboo"
	EnvBitBucketPipelines = "BitBucket Pipelines"
	EnvTravisCI           = "Travis CI"
	EnvCircleCI           = "Circle CI"
	EnvGitLabCI           = "GitLab CI"
	EnvJenkins            = "Jenkins"
	EnvAwsCodeBuild       = "AWS CodeBuild"
	EnvGoogleCloudBuild   = "Google Cloud Build"
	EnvTeamCity           = "TeamCity"
	EnvJetBrainsSpace     = "JetBrains Space"
	EnvCodespaces         = "GitHub Codespaces"

	EnvModifierAzureSpace = "Azure App Spaces Portal"
)

All possible enumerations of ExecutionEnvironmentKey

Environments are mutually exclusive. Modifiers can be set additionally to signal different types of usages. An execution environment is formatted as follows: `<environment>[;<modifier1>;<modifier2>...]`

View Source
const (
	// A user.
	AccountTypeUser = "User"
	// A service principal, typically an application.
	AccountTypeServicePrincipal = "Service Principal"
)

All possible enumerations of AccountTypeKey

View Source
const (
	// Number of tenants found
	AccountSubscriptionsListTenantsFound = attribute.Key("tenants.found")
	// Number of tenants where listing of subscriptions failed
	AccountSubscriptionsListTenantsFailed = attribute.Key("tenants.failed")
)

Additional fields of events.AccountSubscriptionsListEvent

View Source
const (
	// Error code that describes an error.
	ErrCode = attribute.Key("error.code")

	// Inner error.
	ErrInner = attribute.Key("error.inner")

	// The frame of the error.
	ErrFrame = attribute.Key("error.frame")
)

Error related fields

View Source
const (
	// Hostname of the service.
	// The list of allowed values can be found in [Domains].
	ServiceHost = attribute.Key("service.host")

	// Name of the service.
	ServiceName = attribute.Key("service.name")

	// Status code of a response returned by the service.
	// For HTTP, this corresponds to the HTTP status code.
	ServiceStatusCode = attribute.Key("service.statusCode")

	// Method of a request to the service.
	// For HTTP, this corresponds to the HTTP method of the request made.
	ServiceMethod = attribute.Key("service.method")

	// An error code returned by the service in a response.
	// For HTTP, the error code can be found in the response header or body.
	ServiceErrorCode = attribute.Key("service.errorCode")

	// Correlation ID for a request to the service.
	ServiceCorrelationId = attribute.Key("service.correlationId")
)

Service related fields.

View Source
const (
	// The name of the tool.
	ToolName = attribute.Key("tool.name")

	// The exit code of the tool after invocation.
	ToolExitCode = attribute.Key("tool.exitCode")
)

Tool related fields

View Source
const (
	// The builder image used. Hashed when a user-defined image is used.
	PackBuilderImage = attribute.Key("pack.builder.image")

	// The tag of the builder image used. Hashed when a user-defined image is used.
	PackBuilderTag = attribute.Key("pack.builder.tag")
)

Pack related fields

View Source
const (
	InitMethod = attribute.Key("init.method")

	AppInitDetectedDatabase = attribute.Key("appinit.detected.databases")
	AppInitDetectedServices = attribute.Key("appinit.detected.services")

	AppInitConfirmedDatabases = attribute.Key("appinit.confirmed.databases")
	AppInitConfirmedServices  = attribute.Key("appinit.confirmed.services")

	AppInitModifyAddCount    = attribute.Key("appinit.modify_add.count")
	AppInitModifyRemoveCount = attribute.Key("appinit.modify_remove.count")

	// The last step recorded during the app init process.
	AppInitLastStep = attribute.Key("appinit.lastStep")
)

Initialization from app related fields

View Source
const (
	// Logical name of the method from the RPC interface
	// perspective, which can be different from the name of any implementing
	// method/function. See semconv.RPCMethodKey.
	RpcMethod = semconv.RPCMethodKey

	// `id` property of JSON-RPC request or response.
	JsonRpcId = semconv.RPCJsonrpcRequestIDKey

	// `error_code` property of JSON-RPC request or response. Type: int.
	JsonRpcErrorCode = semconv.RPCJsonrpcErrorCodeKey
)

JSON-RPC related fields

View Source
const (
	// Hashed environment name
	EnvNameKey = attribute.Key("env.name")
)

Environment related attributes

View Source
const (
	// The assignment context as returned by the experimentation platform.
	ExpAssignmentContextKey = attribute.Key("exp.assignmentContext")
)

Fields related to the experimentation platform

View Source
const (
	// The time spent waiting on user interaction in milliseconds.
	PerfInteractTime = attribute.Key("perf.interact_time")
)

Performance related fields

View Source
const (
	PlatformTypeKey = attribute.Key("platform.type")
)

Platform related attributes for integrations like devcenter / ADE

View Source
const ServiceNameAzd = "azd"

The value used for ServiceNameKey

Variables

View Source
var Domains = []Domain{

	{"dev.azure.com", "azdo"},
	{"management.azure.com", "arm"},
	{"management.core.windows.net", "arm"},
	{"graph.microsoft.com", "graph"},
	{"graph.windows.net", "graph"},
	{"azmk8s.io", "aks"},
	{"azure-api.net", "apim"},
	{"azure-mobile.net", "mobile"},
	{"azurecontainerapps.io", "aca"},
	{"azurecr.io", "acr"},
	{"azureedge.net", "edge"},
	{"azurefd.net", "frontdoor"},
	{"scm.azurewebsites.net", "kudu"},
	{"azurewebsites.net", "websites"},
	{"blob.core.windows.net", "blob"},
	{"cloudapp.azure.com", "vm"},
	{"cloudapp.net", "vm"},
	{"cosmos.azure.com", "cosmos"},
	{"database.windows.net", "sql"},
	{"documents.azure.com", "cosmos"},
	{"file.core.windows.net", "files"},
	{"origin.mediaservices.windows.net", "media"},
	{"queue.core.windows.net", "queue"},
	{"servicebus.windows.net", "servicebus"},
	{"table.core.windows.net", "table"},
	{"trafficmanager.net", "trafficmanager"},
	{"vault.azure.net", "keyvault"},
	{"visualstudio.com", "vs"},
	{"vo.msecnd.net", "cdn"},
}

Well-known domains. Domains can also be subdomains, thus should be evaluated as such.

Taken from https://learn.microsoft.com/azure/security/fundamentals/azure-domains.

Functions

func CaseInsensitiveHash

func CaseInsensitiveHash(value string) string

func CaseInsensitiveSliceHash

func CaseInsensitiveSliceHash(value []string) []string

func ErrorKey

func ErrorKey(k attribute.Key) attribute.Key

ErrorKey returns a new Key with "error." prefix appended.

func Sha256Hash

func Sha256Hash(val string) string

Sha256Hash returns the hex-encoded Sha256 hash of the given string.

func StringHashed

func StringHashed(k attribute.Key, v string) attribute.KeyValue

func StringSliceHashed

func StringSliceHashed(k attribute.Key, v []string) attribute.KeyValue

Types

type Domain

type Domain struct {
	// The domain name.
	Name string
	// The name of the service that is responsible for the domain name.
	Service string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL