小编Med*_* V.的帖子

Google API Gateway:在标头中提供 API 密钥

我正在尝试设置 Google API Gateway 以使用调用者在标头中发送的 API 密钥。
我的 api 配置 yaml 如下所示:

...
securityDefinitions:
  api_key_header:
    type: apiKey
    name: key
    in: header
  api_key_query:
    type: apiKey
    name: key
    in: query
paths:
  /foo-header:
    get:
      summary: Test foo endpoint
      operationId: testGet-header
      x-google-backend:
        address: "<backend address>"
        protocol: h2
        path_translation: APPEND_PATH_TO_ADDRESS
      security:
        - api_key_header: []
      responses:
        204:
          description: A successful response
  /foo-query:
    get:
      summary: Test foo endpoint
      operationId: testGet-header
      x-google-backend:
        address: "<backend address>"
        protocol: h2
        path_translation: APPEND_PATH_TO_ADDRESS
      security:
        - api_key_query: []
      responses:
        204:
          description: A successful …
Run Code Online (Sandbox Code Playgroud)

google-cloud-platform google-api-gateway

8
推荐指数
1
解决办法
5560
查看次数

如何在 Cloud Run 上使用 Stackdriver 日志记录

我正在尝试让 Stackdriver 日志记录适用于在 Google Cloud Run(完全托管)中运行的简单 Go 应用程序,但在 CloudRun 日志中看不到 stackdriver 条目。

我已经基于“官方”stackdriver golang 示例创建了最简单的演示应用程序

Cloud Run 文档指出不应执行其他操作来写入堆栈驱动程序日志

我的服务使用默认服务帐户

我正在使用 Go 1.13 编译代码(Dockerfile 是从Cloud Run 示例“按原样”复制的)

我试图将它部署到不同的地区,但没有成功

在本地运行容器时,使用服务帐户凭据,本地终端或 stackdriver 控制台中不会出现 stackdriver 日志消息

无论如何,在应用程序启动时,我只看到"Before stackdriver logging"后面"After stackdriver logging"没有其他消息\中间有错误

日志查看截图

这是日志记录代码的一部分(使用上面的链接获取完整源代码、Dockerfile 以及构建和运行应用程序的说明):

import (
    "context"
    "log"
    "os"
    ...

    "cloud.google.com/go/compute/metadata"
    "cloud.google.com/go/logging"
)

func main() {
    loggingClient, err := stackdriverClient()
    ...
    log.Println("Before stackdriver logging")
    logger.StandardLogger(logging.Info).Println("Stackdriver log")
    if err = logger.Flush(); err != nil { …
Run Code Online (Sandbox Code Playgroud)

logging go gcloud google-cloud-stackdriver google-cloud-run

7
推荐指数
1
解决办法
2599
查看次数

Quarkus 本机模式下的手动上下文传播

我正在尝试让上下文传播在 Quarkus 本机模式下工作。
下面的代码在 JVM 模式下按预期工作,但MDC value: null在本机模式下返回。
我所说的“如预期”是指:
响应curl http://localhost:8080/thread-contextMDC value: from-thread-context

@Inject
ManagedExecutor managedExecutor;

@Inject
ThreadContext threadContext;

private final Supplier<String> mdcValueSupplier =
        () -> "MDC value:  " + MDC.get("foo") + "\n";

@GET
@Path("thread-context")
public String get() throws ExecutionException, InterruptedException {
    MDC.put("foo", "from-thread-context");
    Supplier<String> ctxSupplier = threadContext.contextualSupplier(mdcValueSupplier);
    return managedExecutor.supplyAsync(ctxSupplier).get();
}

Run Code Online (Sandbox Code Playgroud)

我创建了一个github 存储库,其中包含演示应用程序的完整代码和重现问题的分步说明。

io.quarkus:quarkus-smallrye-context-propagation存在依赖性。
夸库斯版本:1.9.2

问:是我的代码有问题,还是 Quarkus 有问题?

供参考:Quarkus 关于上下文传播的文档

java graalvm quarkus smallrye

1
推荐指数
1
解决办法
3648
查看次数

GCP 工作流程:重新运行失败执行的简单方法

鉴于工作流执行失败(由工作流 ID 和执行 ID 标识),我需要一种相对快速且简单的方法来使用 CLI 工具 ( ) 使用相同的输入有效负载
重新运行它。 询问谷歌并在 stackoverflow 上搜索并没有给我带来任何简单的方法来做到这一点。gcloud

google-cloud-platform gcloud google-workflows

1
推荐指数
1
解决办法
947
查看次数