定制 teamneusta/sentry-tracing-typo3 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

teamneusta/sentry-tracing-typo3

Composer 安装命令:

composer require teamneusta/sentry-tracing-typo3

包简介

Sentry Tracing for TYPO3

README 文档

README

Provides performance monitoring for TYPO3 using Sentry tracing. It provides the same performance information as available in the admin panel TS tracking view.

It additionally provides a DataProcessor to add the tracing request information to the frontend to allow the Sentry frontend JavaScript to add the frontend performance information, tracing both the frontend and backend.

Prerequisites

The extension provides additional functionality on top of networkteam/sentry-client. It requires the networkteam/sentry-client extension to be installed and configured as it uses the same basic Sentry configuration.

Installation

Install the extension using composer:

composer require neusta/sentry-tracing-typo3

Configuration

Go to the extension configuration and enable the tracing functionality. You can configure the sampling rate (where 0.2 means 20% of requests are traced). For testing purposes, you can set the sampling rate to 1.0 to trace all requests.

Frontend tracing

This extension does not provide frontend tracing out of the box. You need to add the Sentry frontend JavaScript to your frontend. See the Sentry documentation for details (https://docs.sentry.io/platforms/javascript/ - heavily depends on your frontend setup).

You can use the provided DataProcessor to add the tracing information to the frontend to be able to connect backend and frontend traces. Add the DataProcessor to your page rendering configuration:

For example:

page.10.dataProcessing.100 = Neusta\SentryTracing\DataProcessing\SentryTraceProcessor

You can then access the tracing information in Fluid.

Be aware that the tracing information may be cached, depending on how and where you include the meta tags.

If you have a meta tag viewhelper in your project, you can add the tracing information to the corresponding meta tags:

    <nsd:metaTag content="{sentry.baggage}" name="baggage"/>
    <nsd:metaTag content="{sentry.trace}" name="sentry-trace"/>

An example meta tag view helper could look like this (inspired by the news extension):

<?php
declare(strict_types=1);
namespace Neusta\Theme\ViewHelpers;

use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;

final class MetaTagViewHelper extends AbstractViewHelper
{
    use CompileWithRenderStatic;

    /**
     * Arguments initialization
     */
    public function initializeArguments()
    {
        $this->registerArgument('property', 'string', 'Property of meta tag', false, '', false);
        $this->registerArgument('name', 'string', 'Content of meta tag using the name attribute', false, '', false);
        $this->registerArgument('content', 'string', 'Content of meta tag', true, null, false);
        $this->registerArgument('useCurrentDomain', 'boolean', 'Use current domain', false, false);
        $this->registerArgument('forceAbsoluteUrl', 'boolean', 'Force absolut domain', false, false);
        $this->registerArgument('replace', 'boolean', 'Replace potential existing tag', false, false);
    }

    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
    {
        $useCurrentDomain = $arguments['useCurrentDomain'];
        $forceAbsoluteUrl = $arguments['forceAbsoluteUrl'];
        $content = (string)$arguments['content'];

        // set current domain
        if ($useCurrentDomain) {
            $content = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
        }

        // prepend current domain
        if ($forceAbsoluteUrl) {
            $parsedPath = parse_url($content);
            if (is_array($parsedPath) && !isset($parsedPath['host'])) {
                $content =
                    rtrim(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), '/')
                    . '/'
                    . ltrim($content, '/');
            }
        }

        if ($content !== '') {
            $registry = GeneralUtility::makeInstance(MetaTagManagerRegistry::class);
            if ($arguments['property']) {
                $manager = $registry->getManagerForProperty($arguments['property']);
                $manager->addProperty($arguments['property'], $content, [], $arguments['replace'], 'property');
            } elseif ($arguments['name']) {
                $manager = $registry->getManagerForProperty($arguments['name']);
                $manager->addProperty($arguments['name'], $content, [], $arguments['replace'], 'name');
            }
        }
    }
}

统计信息

  • 总下载量: 2.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 7
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2023-07-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固