Members
(constant) arrify
This is a helper library for synchronously writing logs to any transport.
(constant) entry_1
Common construct and functions used by both Log and LogSync
(constant) gapicConfig
Client JSON configuration object, loaded from
src/v2/metrics_service_v2_client_config.json
.
This file defines retry strategy and timeouts for all API methods in this library.
(constant) gapicConfig
Client JSON configuration object, loaded from
src/v2/config_service_v2_client_config.json
.
This file defines retry strategy and timeouts for all API methods in this library.
(constant) gapicConfig
Client JSON configuration object, loaded from
src/v2/logging_service_v2_client_config.json
.
This file defines retry strategy and timeouts for all API methods in this library.
v2
Reference to the low-level auto-generated clients for the V2 Logging service.
Properties:
Name | Type | Description |
---|---|---|
LoggingServiceV2Client |
constructor |
Reference to v2.LoggingServiceV2Client |
ConfigServiceV2Client |
constructor |
Reference to v2.ConfigServiceV2Client |
MetricsServiceV2Client |
constructor |
Reference to v2.MetricsServiceV2Client |
W3C_TRACE_PARENT_HEADER
Header that carries span context across W3C compliant infrastructure.
X_CLOUD_TRACE_HEADER
Header that carries span context across Google infrastructure.
Methods
decodeValue(value) → {*}
Decode a protobuf Struct's value.
Parameters:
Name | Type | Description |
---|---|---|
value |
object |
A Struct's Field message. |
Returns:
Type | Description |
---|---|
* |
|
(async) detectServiceContext()
For logged errors, users can provide a service context. This enables errors to be picked up Cloud Error Reporting. For more information see this guide and the official documentation.
formatLogName(projectId, name)
Format the name of a log. A log's full name is in the format of 'projects/{projectId}/logs/{logName}'.
Parameters:
Name | Type | Description |
---|---|---|
projectId |
||
name |
(async) getCloudFunctionDescriptor() → {object}
Create a descriptor for Cloud Functions.
Returns:
Type | Description |
---|---|
object |
(async) getCloudRunDescriptor() → {object}
Create a descriptor for Cloud Run.
Returns:
Type | Description |
---|---|
object |
getContextFromTraceParent(headerWrapper, projectId)
getOrInjectTraceParent looks for the HTTP header 'traceparent' per W3C specifications for OpenTelemetry and OpenCensus Read more about W3C protocol: https://www.w3.org/TR/trace-context/
Parameters:
Name | Type | Description |
---|---|---|
headerWrapper |
||
projectId |
getContextFromXCloudTrace(headerWrapper, projectId)
getContextFromXCloudTrace looks for the HTTP header 'x-cloud-trace-context' per Google Cloud specifications for Cloud Tracing.
Parameters:
Name | Type | Description |
---|---|---|
headerWrapper |
||
projectId |
(async) getDefaultResource()
Attempt to contact the metadata service and determine, based on request success and environment variables, what type of resource the library is operating on.
(async) getGAEDescriptor() → {object}
Create a descriptor for Google App Engine.
Returns:
Type | Description |
---|---|
object |
(async) getGCEDescriptor() → {object}
Create a descriptor for Google Compute Engine.
Returns:
Type | Description |
---|---|
object |
(async) getGKEDescriptor() → {object}
Create a descriptor for Google Container Engine.
Returns:
Type | Description |
---|---|
object |
getGlobalDescriptor() → {object}
Create a global descriptor.
Returns:
Type | Description |
---|---|
object |
getOrInjectContext(req, projectId, inject)
getOrInjectContext returns a CloudTraceContext with as many available trace and span properties as possible. It examines HTTP headers for trace context. Optionally, it can inject a Google compliant trace context when no context is available from headers.
Parameters:
Name | Type | Description |
---|---|---|
req |
||
projectId |
||
inject |
isRawHttpRequest(req)
isRawHttpRequest detects whether a request object extends the http.IncomingMessage class. It should return true on HTTP compliant requests and all requests created by an http.Server.
Parameters:
Name | Type | Description |
---|---|---|
req |
makeCloudTraceHeader()
makeCloudTraceHeader generates valid X-Cloud-Trace-Context trace and spanId.
makeHeaderWrapper(req)
makeHeaderWrapper returns a wrapper with set and get header functionality, returning null if the incoming request object doesn't contain the 'header' propery.
Parameters:
Name | Type | Description |
---|---|---|
req |
makeHttpRequestData(req, res, latencyMilliseconds)
makeHttpRequestData turns raw incoming HTTPRequests into structured HTTPRequest objects interpreted by Cloud Logging.
Parameters:
Name | Type | Description |
---|---|---|
req |
||
res |
||
latencyMilliseconds |
makeMiddleware(projectId, makeChildLogger, emitRequestLog)
Generates an express middleware that installs a request-specific logger on
the request
object. It optionally can do HttpRequest timing that can be
used for generating request logs. This can be used to integrate with logging
libraries such as winston and bunyan.
Parameters:
Name | Type | Description |
---|---|---|
projectId |
Generated traceIds will be associated with this project. |
|
makeChildLogger |
A function that generates logger instances that will
be installed onto |
|
emitRequestLog |
Optional. A function that will emit a parent request
log. While some environments like GAE and GCF emit parent request logs
automatically, other environments do not. When provided this function will be
called with a populated |
parseTraceParentHeader(headerWrapper)
parseTraceParentHeader is a custom implementation of the parseTraceParent
function in @opentelemetry-core/trace.
For more information see https://www.w3.org/TR/trace-context/
Parameters:
Name | Type | Description |
---|---|---|
headerWrapper |
parseXCloudTraceHeader(headerWrapper)
parseXCloudTraceHeader looks for trace context in X-Cloud-Trace-Context
header
Parameters:
Name | Type | Description |
---|---|---|
headerWrapper |
snakecaseKeys(labels)
snakecaseKeys turns label keys from camel case to snake case.
Parameters:
Name | Type | Description |
---|---|---|
labels |
toCloudTraceContext(anyContext, context, projectId)
toCloudTraceContext converts any context format to cloudTraceContext format.
Parameters:
Name | Type | Description |
---|---|---|
anyContext |
||
context |
||
projectId |
zuluToDateObj(zuluTime)
zuluToDateObj RFC3339 "Zulu" timestamp into a format that can be parsed to a JS Date Object.
Parameters:
Name | Type | Description |
---|---|---|
zuluTime |
Type Definitions
ClientConfig
Properties:
Name | Type | Attributes | Default | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
projectId |
string |
<optional> |
The project ID from the Google Developer's
Console, e.g. 'grape-spaceship-123'. We will also check the environment
variable |
|||||||||||||
keyFilename |
string |
<optional> |
Full path to the a .json, .pem, or .p12 key
downloaded from the Google Developers Console. If you provide a path to a
JSON file, the |
|||||||||||||
email |
string |
<optional> |
Account email address. Required when using a .pem or .p12 keyFilename. |
|||||||||||||
credentials |
object |
<optional> |
Credentials object. Properties
|
|||||||||||||
autoRetry |
boolean |
<optional> |
true |
Automatically retry requests if the response is related to rate limits or certain intermittent server errors. We will exponentially backoff subsequent requests by default. |
||||||||||||
maxRetries |
number |
<optional> |
3 |
Maximum number of automatic retries attempted before returning the error. |
||||||||||||
promise |
Constructor |
<optional> |
Custom promise module to use instead of native Promises. |
TailEntriesRequest
Query object for streaming entries.
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resourceNames |
Array.<string> | string |
<optional> |
Names of project resources to stream logs out of. |
|
filter |
string |
<optional> |
An advanced logs filter. An empty filter matches all log entries. |
|
bufferWindow |
number |
<optional> |
2 |
A setting to balance the tradeoff between viewing the log entries as they are being written and viewing them in ascending order. |
log |
string |
<optional> |
A name of the log specifying to only return entries from this log. |
|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. |