Google-cloud-php: Log Correlation from App Engine Standard PHP 7.2

Created on 6 Sep 2018  路  14Comments  路  Source: googleapis/google-cloud-php

Hello,

I'm trying to write logs from App Engine Standard on the new PHP 7.2 runtime, but the log correlation back to the main request isn't working out of the box.

From the documentation [1]:

Set the trace identifier in the LogEntry trace field of your app log entries. The expected format is projects/[PROJECT_ID]/traces/[TRACE_ID].

However, the logs get written with just the TRACE_ID in that field, not the full string it expects.

See here:
screenshot 1536228689
vs the entry on the main request:
screenshot 1536228721

I followed it back to the metadata provider [2] which was designed for Flex, which sets it in the old location (the appengine.googleapis.com/trace_id label in the labels array), but I don't see where this is being translated into the tracefield in the main LogEntry.

Can somebody help please?

Thanks,
iamacarpet

logging feature request

Most helpful comment

It might be better to fix it in the App Engine log side. The trace id is globally unique so that the project id part is redundant.

All 14 comments

@iamacarpet thank you for the report! I believe this is the location where the trace is being set on the entry.

It seems as though we should be able to update the linked code to the following:

$options['trace'] = sprintf(
    'projects/%s/trace/%s',
    $this->projectId, // currently this is not accessible in the `PsrLogger`, we will need to devise a way to expose it
    $labels['appengine.googleapis.com/trace_id']
);

/cc @tmatsuo to confirm if this seems like a proper way to proceed.

It might be better to fix it in the App Engine log side. The trace id is globally unique so that the project id part is redundant.

That sounds good to me, I'm in favor of the shorter ID if possible.

A fix App Engine side sounds good, but that implies the fix will take a lot longer.

Do you guys have it logged publicly in the issue tracker?

It'll be handy for us to keep tabs on if they plan to implement it and/or keep an eye on it completion.

@iamacarpet We haven't logged it. It's on my plate, but feel free to do so.

Looks like the Stackdriver team have no plans to fix this any time soon, since all the other libraries for other languages use it they way they've defined... Not to mention App Engine Standard legacy runtimes all write this field with that method.

Any chance we can just get it changed in this library, since it's a 2 min change?

@iamacarpet Sorry for the late reply. We'll make a change for it.

1407 will fix the format of the trace id on App Engine standard 2nd gen, however, there is another bug on the Logging UI side. I'll update when the other issue is fixed.

The next release of google/cloud-core will fix this in the library side, but as I stated before, the UI also has a bug, so we'll keep this open until everything works as expected.

Looks like this is working as expected now in the Logs UI.

@iamacarpet

Thanks for checking! Yes, it's working for the most part, but I think there is still a UI bug where the first request (a.k.a loading request) doesn't correlate the relevant logs. I'll keep you updated.

@tmatsuo is this still an open concern, or has it been resolved?

Unfortunately yes. I'll try to move things forward.

It should be fixed now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fschirl picture fschirl  路  4Comments

matthewgoslett picture matthewgoslett  路  4Comments

ammopt picture ammopt  路  6Comments

dwsupplee picture dwsupplee  路  7Comments

castaneai picture castaneai  路  7Comments