github.com/waldiirawan/apm-agent-go/v2@v2.2.2/model/model.go (about)

     1  // Licensed to Elasticsearch B.V. under one or more contributor
     2  // license agreements. See the NOTICE file distributed with
     3  // this work for additional information regarding copyright
     4  // ownership. Elasticsearch B.V. licenses this file to you under
     5  // the Apache License, Version 2.0 (the "License"); you may
     6  // not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  //     http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing,
    12  // software distributed under the License is distributed on an
    13  // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    14  // KIND, either express or implied.  See the License for the
    15  // specific language governing permissions and limitations
    16  // under the License.
    17  
    18  package model // import "github.com/waldiirawan/apm-agent-go/v2/model"
    19  
    20  import (
    21  	"net/http"
    22  	"net/url"
    23  	"time"
    24  )
    25  
    26  // Service represents the service handling transactions being traced.
    27  type Service struct {
    28  	// Name is the immutable name of the service.
    29  	Name string `json:"name,omitempty"`
    30  
    31  	// Version is the version of the service, if it has one.
    32  	Version string `json:"version,omitempty"`
    33  
    34  	// Environment is the name of the service's environment, if it has
    35  	// one, e.g. "production" or "staging".
    36  	Environment string `json:"environment,omitempty"`
    37  
    38  	// Agent holds information about the Elastic APM agent tracing this
    39  	// service's transactions.
    40  	Agent *Agent `json:"agent,omitempty"`
    41  
    42  	// Framework holds information about the service's framework, if any.
    43  	Framework *Framework `json:"framework,omitempty"`
    44  
    45  	// Language holds information about the programming language in which
    46  	// the service is written.
    47  	Language *Language `json:"language,omitempty"`
    48  
    49  	// Runtime holds information about the programming language runtime
    50  	// running this service.
    51  	Runtime *Runtime `json:"runtime,omitempty"`
    52  
    53  	// Node holds unique information about each service node
    54  	Node *ServiceNode `json:"node,omitempty"`
    55  }
    56  
    57  // Agent holds information about the Elastic APM agent.
    58  type Agent struct {
    59  	// Name is the name of the Elastic APM agent, e.g. "Go".
    60  	Name string `json:"name"`
    61  
    62  	// Version is the version of the Elastic APM agent, e.g. "1.0.0".
    63  	Version string `json:"version"`
    64  }
    65  
    66  // Framework holds information about the framework (typically web)
    67  // used by the service.
    68  type Framework struct {
    69  	// Name is the name of the framework.
    70  	Name string `json:"name"`
    71  
    72  	// Version is the version of the framework.
    73  	Version string `json:"version"`
    74  }
    75  
    76  // Language holds information about the programming language used.
    77  type Language struct {
    78  	// Name is the name of the programming language.
    79  	Name string `json:"name"`
    80  
    81  	// Version is the version of the programming language.
    82  	Version string `json:"version,omitempty"`
    83  }
    84  
    85  // Runtime holds information about the programming language runtime.
    86  type Runtime struct {
    87  	// Name is the name of the programming language runtime.
    88  	Name string `json:"name"`
    89  
    90  	// Version is the version of the programming language runtime.
    91  	Version string `json:"version"`
    92  }
    93  
    94  // ServiceNode holds unique information about each service node
    95  type ServiceNode struct {
    96  	// ConfiguredName holds the name of the service node
    97  	ConfiguredName string `json:"configured_name,omitempty"`
    98  }
    99  
   100  // System represents the system (operating system and machine) running the
   101  // service.
   102  type System struct {
   103  	// Architecture is the system's hardware architecture.
   104  	Architecture string `json:"architecture,omitempty"`
   105  
   106  	// Hostname is the system's hostname.
   107  	Hostname string `json:"hostname,omitempty"`
   108  
   109  	// Platform is the system's platform, or operating system name.
   110  	Platform string `json:"platform,omitempty"`
   111  
   112  	// Container describes the container running the service.
   113  	Container *Container `json:"container,omitempty"`
   114  
   115  	// Kubernetes describes the kubernetes node and pod running the service.
   116  	Kubernetes *Kubernetes `json:"kubernetes,omitempty"`
   117  }
   118  
   119  // Process represents an operating system process.
   120  type Process struct {
   121  	// Pid is the process ID.
   122  	Pid int `json:"pid"`
   123  
   124  	// Ppid is the parent process ID, if known.
   125  	Ppid *int `json:"ppid,omitempty"`
   126  
   127  	// Title is the title of the process.
   128  	Title string `json:"title,omitempty"`
   129  
   130  	// Argv holds the command line arguments used to start the process.
   131  	Argv []string `json:"argv,omitempty"`
   132  }
   133  
   134  // Container represents the container (e.g. Docker) running the service.
   135  type Container struct {
   136  	// ID is the unique container ID.
   137  	ID string `json:"id"`
   138  }
   139  
   140  // Kubernetes describes properties of the Kubernetes node and pod in which
   141  // the service is running.
   142  type Kubernetes struct {
   143  	// Namespace names the Kubernetes namespace in which the pod exists.
   144  	Namespace string `json:"namespace,omitempty"`
   145  
   146  	// Node describes the Kubernetes node running the service's pod.
   147  	Node *KubernetesNode `json:"node,omitempty"`
   148  
   149  	// Pod describes the Kubernetes pod running the service.
   150  	Pod *KubernetesPod `json:"pod,omitempty"`
   151  }
   152  
   153  // KubernetesNode describes a Kubernetes node.
   154  type KubernetesNode struct {
   155  	// Name holds the node name.
   156  	Name string `json:"name,omitempty"`
   157  }
   158  
   159  // KubernetesPod describes a Kubernetes pod.
   160  type KubernetesPod struct {
   161  	// Name holds the pod name.
   162  	Name string `json:"name,omitempty"`
   163  
   164  	// UID holds the pod UID.
   165  	UID string `json:"uid,omitempty"`
   166  }
   167  
   168  // Cloud represents the cloud in which the service is running.
   169  type Cloud struct {
   170  	// Provider is the cloud provider name, e.g. aws, azure, gcp.
   171  	Provider string `json:"provider"`
   172  
   173  	// Region is the cloud region name, e.g. us-east-1.
   174  	Region string `json:"region,omitempty"`
   175  
   176  	// AvailabilityZone is the cloud availability zone name, e.g. us-east-1a.
   177  	AvailabilityZone string `json:"availability_zone,omitempty"`
   178  
   179  	// Instance holds information about the cloud instance (virtual machine).
   180  	Instance *CloudInstance `json:"instance,omitempty"`
   181  
   182  	// Machine also holds information about the cloud instance (virtual machine).
   183  	Machine *CloudMachine `json:"machine,omitempty"`
   184  
   185  	// Account holds information about the cloud account.
   186  	Account *CloudAccount `json:"account,omitempty"`
   187  
   188  	// Project holds information about the cloud project.
   189  	Project *CloudProject `json:"project,omitempty"`
   190  }
   191  
   192  // CloudInstance holds information about a cloud instance (virtual machine).
   193  type CloudInstance struct {
   194  	// ID holds the cloud instance identifier.
   195  	ID string `json:"id,omitempty"`
   196  
   197  	// ID holds the cloud instance name.
   198  	Name string `json:"name,omitempty"`
   199  }
   200  
   201  // CloudMachine holds information about a cloud instance (virtual machine).
   202  type CloudMachine struct {
   203  	// Type holds the cloud instance type, e.g. t2.medium.
   204  	Type string `json:"type,omitempty"`
   205  }
   206  
   207  // CloudAccount holds information about a cloud account.
   208  type CloudAccount struct {
   209  	// ID holds the cloud account identifier.
   210  	ID string `json:"id,omitempty"`
   211  
   212  	// ID holds the cloud account name.
   213  	Name string `json:"name,omitempty"`
   214  }
   215  
   216  // CloudProject holds information about a cloud project.
   217  type CloudProject struct {
   218  	// ID holds the cloud project identifier.
   219  	ID string `json:"id,omitempty"`
   220  
   221  	// Name holds the cloud project name.
   222  	Name string `json:"name,omitempty"`
   223  }
   224  
   225  // Transaction represents a transaction handled by the service.
   226  type Transaction struct {
   227  	// ID holds the 64-bit hex-encoded transaction ID.
   228  	ID SpanID `json:"id"`
   229  
   230  	// TraceID holds the ID of the trace that this transaction is a part of.
   231  	TraceID TraceID `json:"trace_id"`
   232  
   233  	// ParentID holds the ID of the transaction's parent span or transaction.
   234  	ParentID SpanID `json:"parent_id,omitempty"`
   235  
   236  	// Name holds the name of the transaction.
   237  	Name string `json:"name"`
   238  
   239  	// Type identifies the service-domain specific type of the request,
   240  	// e.g. "request" or "backgroundjob".
   241  	Type string `json:"type"`
   242  
   243  	// Timestamp holds the time at which the transaction started.
   244  	Timestamp Time `json:"timestamp"`
   245  
   246  	// Duration records how long the transaction took to complete,
   247  	// in milliseconds.
   248  	Duration float64 `json:"duration"`
   249  
   250  	// Result holds the result of the transaction, e.g. the status code
   251  	// for HTTP requests.
   252  	Result string `json:"result,omitempty"`
   253  
   254  	// Context holds contextual information relating to the transaction.
   255  	Context *Context `json:"context,omitempty"`
   256  
   257  	// Sampled indicates that the transaction was sampled, and
   258  	// includes all available information. Non-sampled transactions
   259  	// omit Context.
   260  	//
   261  	// If Sampled is unspecified (nil), it is equivalent to setting
   262  	// it to true.
   263  	Sampled *bool `json:"sampled,omitempty"`
   264  
   265  	// SampleRate holds the sample rate in effect when the trace was started,
   266  	// if known. This is used by the server to aggregate transaction metrics.
   267  	SampleRate *float64 `json:"sample_rate,omitempty"`
   268  
   269  	// SpanCount holds statistics on spans within a transaction.
   270  	SpanCount SpanCount `json:"span_count"`
   271  
   272  	// DroppedSpansStats holds information about spans that were dropped
   273  	// (for example due to transaction_max_spans or exit_span_min_duration).
   274  	DroppedSpansStats []DroppedSpansStats `json:"dropped_spans_stats,omitempty"`
   275  
   276  	// Outcome holds the transaction outcome: success, failure, or unknown.
   277  	Outcome string `json:"outcome,omitempty"`
   278  
   279  	// OTel holds information bridged from OpenTelemetry.
   280  	OTel *OTel `json:"otel,omitempty"`
   281  
   282  	// FAAS holds Function-as-a-Service properties for the transaction.
   283  	FAAS *FAAS `json:"faas,omitempty"`
   284  
   285  	// Links holds a list of spans linked to the transaction.
   286  	Links []SpanLink `json:"links,omitempty"`
   287  }
   288  
   289  // OTel holds bridged OpenTelemetry information.
   290  type OTel struct {
   291  	SpanKind   string                 `json:"span_kind"`
   292  	Attributes map[string]interface{} `json:"attributes,omitempty"`
   293  }
   294  
   295  // SpanCount holds statistics on spans within a transaction.
   296  type SpanCount struct {
   297  	// Dropped holds the number of spans dropped within a transaction.
   298  	// This does not include spans that were started and dropped due
   299  	// to full buffers, network errors, etc.
   300  	Dropped int `json:"dropped"`
   301  
   302  	// Started holds the number of spans started within a transaction.
   303  	Started int `json:"started"`
   304  }
   305  
   306  // DroppedSpansStats holds information about spans that were dropped
   307  // (for example due to transaction_max_spans or exit_span_min_duration).
   308  type DroppedSpansStats struct {
   309  	// DestinationServiceResource identifies the destination service resource
   310  	// being operated on. e.g. 'http://elastic.co:80', 'elasticsearch', 'rabbitmq/queue_name'.
   311  	DestinationServiceResource string `json:"destination_service_resource"`
   312  	// ServiceTargetType holds the target type.
   313  	ServiceTargetType string `json:"service_target_type,omitempty"`
   314  	// ServiceTargetName holds the target name.
   315  	ServiceTargetName string `json:"service_target_name,omitempty"`
   316  	// Outcome of the span: success, failure, or unknown. Outcome may be one of
   317  	// a limited set of permitted values describing the success or failure of
   318  	// the span. It can be used for calculating error rates for outgoing requests.
   319  	Outcome string `json:"outcome"`
   320  	// Duration holds duration aggregations about the dropped span.
   321  	Duration AggregateDuration `json:"duration"`
   322  }
   323  
   324  // AggregateDuration duration
   325  type AggregateDuration struct {
   326  	// Count holds the number of times the dropped span happened.
   327  	Count int `json:"count"`
   328  	// Sum holds dimensions about the dropped span's duration.
   329  	Sum DurationSum `json:"sum"`
   330  }
   331  
   332  // DurationSum contains units for duration
   333  type DurationSum struct {
   334  	// Sum of the duration of a span in Microseconds.
   335  	Us int64 `json:"us"`
   336  }
   337  
   338  // Span represents a span within a transaction.
   339  type Span struct {
   340  	// Name holds the name of the span.
   341  	Name string `json:"name"`
   342  
   343  	// Timestamp holds the time at which the span started.
   344  	Timestamp Time `json:"timestamp"`
   345  
   346  	// Duration holds the duration of the span, in milliseconds.
   347  	Duration float64 `json:"duration"`
   348  
   349  	// Type identifies the overarching type of the span,
   350  	// e.g. "db" or "external".
   351  	Type string `json:"type"`
   352  
   353  	// Subtype identifies the subtype of the span,
   354  	// e.g. "mysql" or "http".
   355  	Subtype string `json:"subtype,omitempty"`
   356  
   357  	// Action identifies the action that is being undertaken, e.g. "query".
   358  	Action string `json:"action,omitempty"`
   359  
   360  	// ID holds the ID of the span.
   361  	ID SpanID `json:"id"`
   362  
   363  	// TransactionID holds the ID of the transaction of which the span is a part.
   364  	TransactionID SpanID `json:"transaction_id,omitempty"`
   365  
   366  	// TraceID holds the ID of the trace that this span is a part of.
   367  	TraceID TraceID `json:"trace_id"`
   368  
   369  	// ParentID holds the ID of the span's parent (span or transaction).
   370  	ParentID SpanID `json:"parent_id,omitempty"`
   371  
   372  	// SampleRate holds the sample rate in effect when the trace was started,
   373  	// if known. This is used by the server to aggregate span metrics.
   374  	SampleRate *float64 `json:"sample_rate,omitempty"`
   375  
   376  	// Context holds contextual information relating to the span.
   377  	Context *SpanContext `json:"context,omitempty"`
   378  
   379  	// Stacktrace holds stack frames corresponding to the span.
   380  	Stacktrace []StacktraceFrame `json:"stacktrace,omitempty"`
   381  
   382  	// Outcome holds the span outcome: success, failure, or unknown.
   383  	Outcome string `json:"outcome,omitempty"`
   384  
   385  	// Composite is set when the span is a composite span and represents an
   386  	// aggregated set of spans as defined by `composite.compression_strategy`.
   387  	Composite *CompositeSpan `json:"composite,omitempty"`
   388  
   389  	// Links holds a list of spans linked to the span.
   390  	Links []SpanLink `json:"links,omitempty"`
   391  
   392  	// OTel holds information bridged from OpenTelemetry.
   393  	OTel *OTel `json:"otel,omitempty"`
   394  }
   395  
   396  // SpanContext holds contextual information relating to the span.
   397  type SpanContext struct {
   398  	// Destination holds information about a destination service.
   399  	Destination *DestinationSpanContext `json:"destination,omitempty"`
   400  
   401  	// Service holds information about the service.
   402  	Service *ServiceSpanContext `json:"service,omitempty"`
   403  
   404  	// Database holds contextual information for database
   405  	// operation spans.
   406  	Database *DatabaseSpanContext `json:"db,omitempty"`
   407  
   408  	// Message holds contextual information for message operation spans.
   409  	Message *MessageSpanContext `json:"message,omitempty"`
   410  
   411  	// HTTP holds contextual information for HTTP client request spans.
   412  	HTTP *HTTPSpanContext `json:"http,omitempty"`
   413  
   414  	// Tags holds user-defined key/value pairs.
   415  	Tags IfaceMap `json:"tags,omitempty"`
   416  }
   417  
   418  // SpanLink holds the information of a linked span.
   419  type SpanLink struct {
   420  	TraceID TraceID `json:"trace_id"`
   421  	SpanID  SpanID  `json:"span_id"`
   422  }
   423  
   424  // DestinationSpanContext holds contextual information about the destination
   425  // for a span that relates to an operation involving an external service.
   426  type DestinationSpanContext struct {
   427  	// Address holds the network address of the destination service.
   428  	// This may be a hostname, FQDN, or (IPv4 or IPv6) network address.
   429  	Address string `json:"address,omitempty"`
   430  
   431  	// Port holds the network port for the destination service.
   432  	Port int `json:"port,omitempty"`
   433  
   434  	// Service holds additional destination service context.
   435  	Service *DestinationServiceSpanContext `json:"service,omitempty"`
   436  
   437  	// Cloud holds additional destination cloud context.
   438  	Cloud *DestinationCloudSpanContext `json:"cloud,omitempty"`
   439  }
   440  
   441  // ServiceSpanContext holds contextual information about the service
   442  // for a span that relates to an operation involving an external service.
   443  type ServiceSpanContext struct {
   444  	// Target holds the destination service.
   445  	Target *ServiceTargetSpanContext `json:"target,omitempty"`
   446  }
   447  
   448  // ServiceTargetSpanContext fields replace the `span.destination.service.*`
   449  // fields that are deprecated.
   450  type ServiceTargetSpanContext struct {
   451  	// Type holds the destination service type.
   452  	Type string `json:"type"`
   453  
   454  	// Name holds the destination service name.
   455  	Name string `json:"name,omitempty"`
   456  }
   457  
   458  // DestinationServiceSpanContext holds contextual information about a
   459  // destination service.
   460  //
   461  // Deprecated: replaced by `service.target.{type,name}`.
   462  type DestinationServiceSpanContext struct {
   463  	// Type holds the destination service type. Deprecated.
   464  	//
   465  	// Deprecated: replaced by `service.target.{type,name}`.
   466  	Type string `json:"type,omitempty"`
   467  
   468  	// Name holds the destination service name. Deprecated.
   469  	//
   470  	// Deprecated: replaced by `service.target.{type,name}`.
   471  	Name string `json:"name"`
   472  
   473  	// Resource identifies the destination service
   474  	// resource, e.g. a URI or message queue name.
   475  	//
   476  	// Deprecated: replaced by `service.target.{type,name}`.
   477  	Resource string `json:"resource,omitempty"`
   478  }
   479  
   480  // DestinationCloudSpanContext holds contextual information about a
   481  // destination cloud.
   482  type DestinationCloudSpanContext struct {
   483  	// Region holds the destination cloud region.
   484  	Region string `json:"region,omitempty"`
   485  }
   486  
   487  // MessageSpanContext holds contextual information about a message.
   488  type MessageSpanContext struct {
   489  	// Queue holds the destination cloud region.
   490  	Queue *MessageQueueSpanContext `json:"queue,omitempty"`
   491  }
   492  
   493  // MessageQueueSpanContext holds contextual information about a message queue.
   494  type MessageQueueSpanContext struct {
   495  	// Name holds the message queue name.
   496  	Name string `json:"name,omitempty"`
   497  }
   498  
   499  // DatabaseSpanContext holds contextual information for database
   500  // operation spans.
   501  type DatabaseSpanContext struct {
   502  	// Instance holds the database instance name.
   503  	Instance string `json:"instance,omitempty"`
   504  
   505  	// Statement holds the database statement (e.g. query).
   506  	Statement string `json:"statement,omitempty"`
   507  
   508  	// RowsAffected holds the number of rows affected by the
   509  	// database operation.
   510  	RowsAffected *int64 `json:"rows_affected,omitempty"`
   511  
   512  	// Type holds the database type. For any SQL database,
   513  	// this should be "sql"; for others, the lower-cased
   514  	// database category, e.g. "cassandra", "hbase", "redis".
   515  	Type string `json:"type,omitempty"`
   516  
   517  	// User holds the username used for database access.
   518  	User string `json:"user,omitempty"`
   519  }
   520  
   521  // HTTPSpanContext holds contextual information for HTTP client request spans.
   522  type HTTPSpanContext struct {
   523  	// URL is the request URL.
   524  	URL *url.URL
   525  
   526  	// StatusCode holds the HTTP response status code.
   527  	StatusCode int `json:"status_code,omitempty"`
   528  }
   529  
   530  // CompositeSpan holds details on a group of spans represented by a single one.
   531  type CompositeSpan struct {
   532  	// Count is the number of compressed spans the composite span represents.
   533  	// The minimum count is 2, as a composite span represents at least two spans.
   534  	Count int `json:"count"`
   535  	// Sum is the durations of all compressed spans this composite span
   536  	// represents in milliseconds.
   537  	Sum float64 `json:"sum"`
   538  	// A string value indicating which compression strategy was used. The valid
   539  	// values are `exact_match` and `same_kind`.
   540  	CompressionStrategy string `json:"compression_strategy"`
   541  }
   542  
   543  // Context holds contextual information relating to a transaction or error.
   544  type Context struct {
   545  	// Custom holds custom context relating to the transaction or error.
   546  	Custom IfaceMap `json:"custom,omitempty"`
   547  
   548  	// Request holds details of the HTTP request relating to the
   549  	// transaction or error, if relevant.
   550  	Request *Request `json:"request,omitempty"`
   551  
   552  	// Response holds details of the HTTP response relating to the
   553  	// transaction or error, if relevant.
   554  	Response *Response `json:"response,omitempty"`
   555  
   556  	// User holds details of the authenticated user relating to the
   557  	// transaction or error, if relevant.
   558  	User *User `json:"user,omitempty"`
   559  
   560  	// Tags holds user-defined key/value pairs.
   561  	Tags IfaceMap `json:"tags,omitempty"`
   562  
   563  	// Service holds values to overrides service-level metadata.
   564  	Service *Service `json:"service,omitempty"`
   565  }
   566  
   567  // User holds information about an authenticated user.
   568  type User struct {
   569  	// Username holds the username of the user.
   570  	Username string `json:"username,omitempty"`
   571  
   572  	// ID identifies the user, e.g. a primary key. This may be
   573  	// a string or number.
   574  	ID string `json:"id,omitempty"`
   575  
   576  	// Email holds the email address of the user.
   577  	Email string `json:"email,omitempty"`
   578  }
   579  
   580  // Error represents an error occurring in the service.
   581  type Error struct {
   582  	// Timestamp holds the time at which the error occurred.
   583  	Timestamp Time `json:"timestamp"`
   584  
   585  	// ID holds the 128-bit hex-encoded error ID.
   586  	ID TraceID `json:"id"`
   587  
   588  	// TraceID holds the ID of the trace within which the error occurred.
   589  	TraceID TraceID `json:"trace_id,omitempty"`
   590  
   591  	// ParentID holds the ID of the transaction within which the error
   592  	// occurred.
   593  	ParentID SpanID `json:"parent_id,omitempty"`
   594  
   595  	// TransactionID holds the ID of the transaction within which the error occurred.
   596  	TransactionID SpanID `json:"transaction_id,omitempty"`
   597  
   598  	// Culprit holds the name of the function which
   599  	// produced the error.
   600  	Culprit string `json:"culprit,omitempty"`
   601  
   602  	// Context holds contextual information relating to the error.
   603  	Context *Context `json:"context,omitempty"`
   604  
   605  	// Exception holds details of the exception (error or panic)
   606  	// to which this error relates.
   607  	Exception Exception `json:"exception,omitempty"`
   608  
   609  	// Log holds additional information added when logging the error.
   610  	Log Log `json:"log,omitempty"`
   611  
   612  	// Transaction holds information about the transaction within which the error occurred.
   613  	Transaction ErrorTransaction `json:"transaction,omitempty"`
   614  }
   615  
   616  // ErrorTransaction holds information about the transaction within which an error occurred.
   617  type ErrorTransaction struct {
   618  	// Sampled indicates that the transaction was sampled.
   619  	Sampled *bool `json:"sampled,omitempty"`
   620  
   621  	// Type holds the transaction type.
   622  	Type string `json:"type,omitempty"`
   623  
   624  	// Name holds the transaction name.
   625  	Name string `json:"name,omitempty"`
   626  }
   627  
   628  // Exception represents an exception: an error or panic.
   629  type Exception struct {
   630  	// Message holds the error message.
   631  	Message string `json:"message"`
   632  
   633  	// Code holds the error code. This may be a number or a string.
   634  	Code ExceptionCode `json:"code,omitempty"`
   635  
   636  	// Type holds the type of the exception.
   637  	Type string `json:"type,omitempty"`
   638  
   639  	// Module holds the exception type's module namespace.
   640  	Module string `json:"module,omitempty"`
   641  
   642  	// Attributes holds arbitrary exception-type specific attributes.
   643  	Attributes map[string]interface{} `json:"attributes,omitempty"`
   644  
   645  	// Stacktrace holds stack frames corresponding to the exception.
   646  	Stacktrace []StacktraceFrame `json:"stacktrace,omitempty"`
   647  
   648  	// Handled indicates whether or not the error was caught and handled.
   649  	Handled bool `json:"handled"`
   650  
   651  	// Cause holds the causes of this error.
   652  	Cause []Exception `json:"cause,omitempty"`
   653  }
   654  
   655  // ExceptionCode represents an exception code as either a number or a string.
   656  type ExceptionCode struct {
   657  	String string
   658  	Number float64
   659  }
   660  
   661  // StacktraceFrame describes a stack frame.
   662  type StacktraceFrame struct {
   663  	// AbsolutePath holds the absolute path of the source file for the
   664  	// stack frame.
   665  	AbsolutePath string `json:"abs_path,omitempty"`
   666  
   667  	// File holds the base filename of the source file for the stack frame.
   668  	File string `json:"filename"`
   669  
   670  	// Line holds the line number of the source for the stack frame.
   671  	Line int `json:"lineno"`
   672  
   673  	// Column holds the column number of the source for the stack frame.
   674  	Column *int `json:"colno,omitempty"`
   675  
   676  	// Module holds the module to which the frame belongs. For Go, we
   677  	// use the package path (e.g. "net/http").
   678  	Module string `json:"module,omitempty"`
   679  
   680  	// Classname holds the name of the class to which the frame belongs.
   681  	Classname string `json:"classname,omitempty"`
   682  
   683  	// Function holds the name of the function to which the frame belongs.
   684  	Function string `json:"function,omitempty"`
   685  
   686  	// LibraryFrame indicates whether or not the frame corresponds to
   687  	// library or user code.
   688  	LibraryFrame bool `json:"library_frame,omitempty"`
   689  
   690  	// ContextLine holds the line of source code to which the frame
   691  	// corresponds.
   692  	ContextLine string `json:"context_line,omitempty"`
   693  
   694  	// PreContext holds zero or more lines of source code preceding the
   695  	// line corresponding to the frame.
   696  	PreContext []string `json:"pre_context,omitempty"`
   697  
   698  	// PostContext holds zero or more lines of source code proceeding the
   699  	// line corresponding to the frame.
   700  	PostContext []string `json:"post_context,omitempty"`
   701  
   702  	// Vars holds local variables for this stack frame.
   703  	Vars map[string]interface{} `json:"vars,omitempty"`
   704  }
   705  
   706  // Log holds additional information added when logging an error.
   707  type Log struct {
   708  	// Message holds the logged error message.
   709  	Message string `json:"message"`
   710  
   711  	// Level holds the severity of the log record.
   712  	Level string `json:"level,omitempty"`
   713  
   714  	// LoggerName holds the name of the logger used.
   715  	LoggerName string `json:"logger_name,omitempty"`
   716  
   717  	// ParamMessage holds a parameterized message,  e.g.
   718  	// "Could not connect to %s". The string is not interpreted,
   719  	// but may be used for grouping errors.
   720  	ParamMessage string `json:"param_message,omitempty"`
   721  
   722  	// Stacktrace holds stack frames corresponding to the error.
   723  	Stacktrace []StacktraceFrame `json:"stacktrace,omitempty"`
   724  }
   725  
   726  // Request represents an HTTP request.
   727  type Request struct {
   728  	// URL is the request URL.
   729  	URL URL `json:"url"`
   730  
   731  	// Method holds the HTTP request method.
   732  	Method string `json:"method"`
   733  
   734  	// Headers holds the request headers.
   735  	Headers Headers `json:"headers,omitempty"`
   736  
   737  	// Body holds the request body, if body capture is enabled.
   738  	Body *RequestBody `json:"body,omitempty"`
   739  
   740  	// HTTPVersion holds the HTTP version of the request.
   741  	HTTPVersion string `json:"http_version,omitempty"`
   742  
   743  	// Cookies holds the parsed cookies.
   744  	Cookies Cookies `json:"cookies,omitempty"`
   745  
   746  	// Env holds environment information passed from the
   747  	// web framework to the request handler.
   748  	Env map[string]string `json:"env,omitempty"`
   749  
   750  	// Socket holds transport-level information.
   751  	Socket *RequestSocket `json:"socket,omitempty"`
   752  }
   753  
   754  // Cookies holds a collection of HTTP cookies.
   755  type Cookies []*http.Cookie
   756  
   757  // RequestBody holds a request body.
   758  //
   759  // Exactly one of Raw or Form must be set.
   760  type RequestBody struct {
   761  	// Raw holds the raw body content.
   762  	Raw string
   763  
   764  	// Form holds the form data from POST, PATCH, or PUT body parameters.
   765  	Form url.Values
   766  }
   767  
   768  // Headers holds a collection of HTTP headers.
   769  type Headers []Header
   770  
   771  // Header holds an HTTP header, with one or more values.
   772  type Header struct {
   773  	Key    string
   774  	Values []string
   775  }
   776  
   777  // RequestSocket holds transport-level information relating to an HTTP request.
   778  type RequestSocket struct {
   779  	// Encrypted indicates whether or not the request was sent
   780  	// as an SSL/HTTPS request. Deprecated.
   781  	Encrypted bool `json:"encrypted,omitempty"`
   782  
   783  	// RemoteAddress holds the remote address for the request.
   784  	RemoteAddress string `json:"remote_address,omitempty"`
   785  }
   786  
   787  // URL represents a server-side (transaction) request URL,
   788  // broken down into its constituent parts.
   789  type URL struct {
   790  	// Full is the full URL, e.g.
   791  	// "https://example.com:443/search/?q=elasticsearch#top".
   792  	Full string `json:"full,omitempty"`
   793  
   794  	// Protocol is the scheme of the URL, e.g. "https".
   795  	Protocol string `json:"protocol,omitempty"`
   796  
   797  	// Hostname is the hostname for the URL, e.g. "example.com".
   798  	Hostname string `json:"hostname,omitempty"`
   799  
   800  	// Port is the port number in the URL, e.g. "443".
   801  	Port string `json:"port,omitempty"`
   802  
   803  	// Path is the path of the URL, e.g. "/search".
   804  	Path string `json:"pathname,omitempty"`
   805  
   806  	// Search is the query string of the URL, e.g. "q=elasticsearch".
   807  	Search string `json:"search,omitempty"`
   808  
   809  	// Hash is the fragment for references, e.g. "top" in the
   810  	// URL example provided for Full.
   811  	Hash string `json:"hash,omitempty"`
   812  }
   813  
   814  // Response represents an HTTP response.
   815  type Response struct {
   816  	// StatusCode holds the HTTP response status code.
   817  	StatusCode int `json:"status_code,omitempty"`
   818  
   819  	// Headers holds the response headers.
   820  	Headers Headers `json:"headers,omitempty"`
   821  
   822  	// HeadersSent indicates whether or not headers were sent
   823  	// to the client.
   824  	HeadersSent *bool `json:"headers_sent,omitempty"`
   825  
   826  	// Finished indicates whether or not the response was finished.
   827  	Finished *bool `json:"finished,omitempty"`
   828  }
   829  
   830  // Time is a timestamp, formatted as a number of microseconds since January 1, 1970 UTC.
   831  type Time time.Time
   832  
   833  // TraceID holds a 128-bit trace ID.
   834  type TraceID [16]byte
   835  
   836  // SpanID holds a 64-bit span ID. Despite its name, this is used for
   837  // both spans and transactions.
   838  type SpanID [8]byte
   839  
   840  // Metrics holds a set of metric samples, with an optional set of labels.
   841  type Metrics struct {
   842  	// Timestamp holds the time at which the metric samples were taken.
   843  	Timestamp Time `json:"timestamp"`
   844  
   845  	// Transaction optionally holds the name and type of transactions
   846  	// with which these metrics are associated.
   847  	Transaction MetricsTransaction `json:"transaction,omitempty"`
   848  
   849  	// Span optionally holds the type and subtype of the spans with
   850  	// which these metrics are associated.
   851  	Span MetricsSpan `json:"span,omitempty"`
   852  
   853  	// Labels holds a set of labels associated with the metrics.
   854  	// The labels apply uniformly to all metric samples in the set.
   855  	//
   856  	// NOTE(axw) the schema calls the field "tags", but we use
   857  	// "labels" for agent-internal consistency. Labels aligns better
   858  	// with the common schema, anyway.
   859  	Labels StringMap `json:"tags,omitempty"`
   860  
   861  	// FAAS holds Function-as-a-Service related properties for the metrics.
   862  	FAAS *FAAS `json:"faas,omitempty"`
   863  
   864  	// Samples holds a map of metric samples, keyed by metric name.
   865  	Samples map[string]Metric `json:"samples"`
   866  }
   867  
   868  // MetricsTransaction holds transaction identifiers for metrics.
   869  type MetricsTransaction struct {
   870  	Type string `json:"type,omitempty"`
   871  	Name string `json:"name,omitempty"`
   872  }
   873  
   874  // MetricsSpan holds span identifiers for metrics.
   875  type MetricsSpan struct {
   876  	Type    string `json:"type,omitempty"`
   877  	Subtype string `json:"subtype,omitempty"`
   878  }
   879  
   880  // Metric holds metric values.
   881  type Metric struct {
   882  	Type string `json:"type,omitempty"`
   883  	// Value holds the metric value.
   884  	Value float64 `json:"value"`
   885  	// Values holds the metric bucket values.
   886  	Values []float64 `json:"values,omitempty"`
   887  	// Counts holds the metric observation count for the bucket.
   888  	Counts []uint64 `json:"counts,omitempty"`
   889  }
   890  
   891  // FAAS holds Function-as-a-Service properties.
   892  type FAAS struct {
   893  	// ID holds a unique identifier of the invoked serverless function.
   894  	ID string `json:"id,omitempty"`
   895  	// Execution holds the request ID of the function invocation.
   896  	Execution string `json:"execution,omitempty"`
   897  	// Trigger holds information related to the trigger of the function invocation.
   898  	Trigger *FAASTrigger `json:"trigger,omitempty"`
   899  	// Name holds the lambda function name.
   900  	Name string `json:"name,omitempty"`
   901  	// Version holds the lambda function version.
   902  	Version string `json:"version,omitempty"`
   903  	// Coldstart indicates if the lambda function triggered a Cold Start
   904  	Coldstart bool `json:"coldstart"`
   905  }
   906  
   907  // FAASTrigger holds information related to the trigger of a Function-as-a-Service invocation.
   908  type FAASTrigger struct {
   909  	// Type holds the trigger type.
   910  	Type string `json:"type,omitempty"`
   911  	// RequestID holds the ID of the origin trigger request.
   912  	RequestID string `json:"request_id,omitempty"`
   913  }